<template>
  <div class="random-video">
    <div class="iframe-box">
      <iframe
      class="iframe-class"
    :src="iframeSrc"
     STYLE="background-color: #fff"
    scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true">
      </iframe>
      <div class="random-button" @click="getRandomVideo"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'randomVideo',
  components: {
  },
  data(){
    return {
      iframeSrc:"",
    }
  },
  created(){
    this.getRandomVideo()
  },
  methods:{
    async getRandomVideo(){
      try {
        this.$loading()
        const res =  await  this.$request('api/stroll/random')
        this.iframeSrc = res.play_url
      } catch (error) {
        this.$message({message:error,type: 'error'})
      }finally{
        this.$closeLoading()
      }

    }
  }
}
</script>

<style lang="less" scoped>
.random-video{
  position: relative;
  // height: 100vh;
  z-index: 0;
  padding-top: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #2B343A;
}
.background-img{
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: -1;
  min-width: 600px;
  min-height: 300px;
  //object-fit: cover;
}
.iframe-box{
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.iframe-class{
  width: 60vw;
  height: 40vw;
  min-width: 300px;
  // min-height: 450px;
  border: 3px solid #c343dc;
}
.random-button{
  background-color: #333;
  cursor: pointer;
  width: 100px;
  height: 100px;
  margin-top: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 20px;
  background: #943fef;
  outline: 1px solid;
  outline-color: rgba(148,63,239, 1);
  background: url("../../assets/img/random/random-button.jpg") no-repeat center /cover;
  -webkit-transition: all 1250ms cubic-bezier(0.19, 1, 0.22, 1);
  transition: all 1250ms cubic-bezier(0.19, 1, 0.22, 1);
  -moz-transition: all 1250ms cubic-bezier(0.19, 1, 0.22, 1); /* Firefox 4 */
  -webkit-transition:all 1250ms cubic-bezier(0.19, 1, 0.22, 1); /* Safari 和 Chrome */
  -o-transition: all 1250ms cubic-bezier(0.19, 1, 0.22, 1); /* Opera */
}
.random-button:hover{
  border: 1 solid;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.2);
  outline: 5px solid;
  outline-color: rgba(148,63,239, 0);
  outline-offset: 20px;
  text-shadow: 1px 1px 2px #427388;
}

@media screen and (max-width: 1170px) {
  .iframe-box{
      flex-direction: column;
      align-items: center;
  }
  .iframe-class{
    width: 80vw;
    height: 60vh;
    margin-top: 70px;
    border: 1px solid #c343dc;
  }
  .random-button{
      width: 80px;
      height: 80px;
  }
}
</style>
